12. Overview of JSON

Overview of JSON

JSON Structure

Curly Braces

You can see that everything in this JSON shoe example is enclosed in a set of curly braces, indicating the whole thing can be treated as an object.

Commas

The keys and values are separated by a colon character, and each key/value pair is separated by a comma character.
Highlight each bit of code as they are mentioned
JSON supports the basic data types that you find in most programming languages, such as numbers, strings, booleans, arrays, and objects. You can see a few of those data types in this example:

Size code

The first key called "size" has a value of 9.5, and you can tell the value is a number because there are no quotation marks around it.

Wide code

The "wide" key has a value of true, with no quotation marks. This indicates that the value is a boolean.
Highlight country of origin
If the number had quotes around it, then it would be a string. And a string is exactly what we find in the second key value pair, where it says "country-of-origin" and then the value is set to "usa".

Style

The next item is "style", and the value of it is represented as an object, as indicated by the curly braces.

Nested values.

Inside of the style object, we can find two nested values: One for categories, and one for color. Coordinates is represented as an array with three values in the array.

Groups of values can be nested in this way, by using objects and arrays, and then you can place different data types inside of those containers.

More Info:

For more info on how JSON is structured, check out http://www.json.org/.